﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.BLL.ContactsManager;
using MS.InformationManagement.DAL.DocumentCenter;
using MS.InformationManagement.Support.Constants;

namespace MS.InformationManagement.Presenter.Contacts
{
    public class ContactosPresenter: BasePresenter<IContactsView>
    {

        #region Constructors

        public ContactosPresenter(IContactsView view) : base(view) { }

        #endregion

        #region Public Methods

        public void HandleSave()
        {
            new BaseContactsAction<Contactos>(View.ContactsEntity).AddContact();
            View.MessageClearFields(GlobalConstants.SUCCESS_CONTACT_SAVE,true);
        }

        public void HandleUpdate()
        {
            new BaseContactsAction<Contactos>(View.ContactsEntity).UpdateContact();
            View.MessageClearFields(GlobalConstants.SUCCESS_CONTACT_UPDATED, false);
        }

        public void HandleLoad()
        {
            if(View.SelectedContactId.HasValue)
                View.ContactsEntity = new BaseContactsAction<Contactos>().GetContact(View.SelectedContactId.Value);
            View.Show();  
        }

        #endregion

    }
}
